from django.urls import path, include
from rest_framework.routers import DefaultRouter


# 分别导入三种视图
from course.views.fbv import course_list, course_detail
from course.views.cbv import CourseList, CourseDetail
from course.views.viewset import CourseViewSet

# 注册 ViewSet 路由
router = DefaultRouter()
router.register(r'viewsets', CourseViewSet, basename='course')

urlpatterns = [

    # Function Based View
    path("fbv/list/", course_list, name="fbv-list"),
    path("fbv/detail/<int:pk>", course_detail, name="fbv-detail"),

    # Class Based View
    path("cbv/list/", CourseList.as_view(), name='cbv-list'),
    path("cbv/detail/<int:pk>/", CourseDetail.as_view(), name='cbv-detail'),

    # ViewSet 自动路由
    path("", include(router.urls)),
]
